import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { StartComponent } from './home/start/start.component';
import {AddTestComponent} from "./home/add-test/add-test.component";
import {TrainingMinuteComponent} from "./home/training-minute/training-minute.component";
import {RosterTrainingComponent} from "./home/roster-training/roster-training.component";
import {RosterTrainingResultComponent} from "./home/roster-training/roster-training-result/roster-training-result.component";
import {TrainingExplainComponent} from "./home/roster-training/training-explain/training-explain.component";
import {QRCodeComponent} from "./home/roster-training/QR-code/QR-code.component";
//路由守卫
import {EnterGuard} from "./my-guard/enter.guard";

export const routes: Routes = [
  //首页
  {
    path: 'home', component: HomeComponent, data: { menu: 'home' },canActivate: [EnterGuard],
    children: [
      { path: 'start', component: StartComponent, data: { menu: 'home', submenu: 'start' } },
      { path: '', redirectTo: 'start', pathMatch: 'full' },
      { path: 'add',component:AddTestComponent },
      { path: 'minute',component:TrainingMinuteComponent },
      { path: 'roster',component:RosterTrainingComponent,
        children:[
          {
            path:'',component:RosterTrainingResultComponent,
          },
          {
            path:'explain',component:TrainingExplainComponent
          },
          {
            path:'code',component:QRCodeComponent
          }
        ]
      },
    ]
  },
  { path: '', redirectTo: 'home', pathMatch: 'full' }
];
@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
  providers: [
    EnterGuard
  ]
})
export class AppRoutingModule { }
